Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@lingui/core
Advanced tools
@lingui/core is a library for internationalization (i18n) in JavaScript applications. It provides tools for managing translations, formatting messages, and handling locale data. It is designed to be flexible and easy to integrate with various frameworks and libraries.
Message Formatting
This feature allows you to format messages with placeholders that can be replaced with dynamic values. The example demonstrates loading a translation, activating a locale, and formatting a message with a dynamic name.
const { i18n } = require('@lingui/core');
const { setupI18n } = require('@lingui/core');
const i18n = setupI18n();
i18n.load({
en: {
message: 'Hello, {name}!'
}
});
i18n.activate('en');
const message = i18n._('message', { name: 'John' });
console.log(message); // Output: Hello, John!
Locale Management
This feature allows you to manage different locales and switch between them. The example shows how to load translations for multiple locales and activate a specific locale to get the translated message.
const { i18n } = require('@lingui/core');
const { setupI18n } = require('@lingui/core');
const i18n = setupI18n();
i18n.load({
en: { message: 'Hello' },
fr: { message: 'Bonjour' }
});
i18n.activate('fr');
const message = i18n._('message');
console.log(message); // Output: Bonjour
Custom Pluralization Rules
This feature allows you to define custom pluralization rules for different languages. The example demonstrates how to use pluralization in a message based on the count value.
const { i18n } = require('@lingui/core');
const { setupI18n } = require('@lingui/core');
const i18n = setupI18n();
i18n.load({
en: {
message: '{count, plural, one {# item} other {# items}}'
}
});
i18n.activate('en');
const message = i18n._('message', { count: 5 });
console.log(message); // Output: 5 items
i18next is a popular internationalization framework for JavaScript. It provides similar functionalities to @lingui/core, such as message formatting, locale management, and pluralization. However, i18next has a larger ecosystem with more plugins and integrations available.
react-intl is a library specifically designed for internationalization in React applications. It offers similar features to @lingui/core, such as message formatting and locale management, but is tightly integrated with React components and hooks.
Globalize is a library for internationalization and localization in JavaScript. It provides functionalities for formatting numbers, dates, and messages, similar to @lingui/core. Globalize is built on top of the Unicode CLDR data and focuses on providing comprehensive localization support.
Internationalization API for JavaScript apps
@lingui/core
is part of LinguiJS. See the documentation for all information, tutorials and examples.
See the tutorial or reference documentation.
This package is licensed under MIT license.
5.1.2 (2024-12-16)
Note: Version bump only for package js-lingui-workspaces
FAQs
I18n tools for javascript
The npm package @lingui/core receives a total of 252,831 weekly downloads. As such, @lingui/core popularity was classified as popular.
We found that @lingui/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.